package com.yzw.hellospringcloudwebadminribbon.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.client.RestTemplate;

/**
 * @Athor:Yuan
 * @Date:2020/4/6 13:15
 * Desc:
 */
@Service
public class AdminService {

    @Autowired
    private RestTemplate restTemplate;
    @HystrixCommand(fallbackMethod = "hiErro")
    public String sayHi(String message) {
        return restTemplate.getForObject("http://HELLO-SPRING-CLOUD-SERVICE-ADMIN/hi?message=" + message, String.class);
    }

    public String hiErro(String message){

        return String.format("Hi,your message is : %s ,but request erro",message);
    }
}
